import sqlite3
from flask import g,Flask

DATABASE = 'Z:/_PROJECT_/Python/flask/templates/A-27.db'
app = Flask(__name__)

def get_db():
    conn = sqlite3.connect(DATABASE)
    db = getattr(g, '_database', None)
    if db is None:
        db = g._database = sqlite3.connect(DATABASE)
    return db

@app.teardown_appcontext
def close_connection(exception):
    db = getattr(g, '_database', None)
    if db is not None:
        db.close()


@app.route('/index')
def index():
    return get_db()


if __name__ == '__main__':
    app.run()